package com.airbat.prize.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum GangRelationTypeEnum {

    PERSON_CASE(0, "人案"),
    LINK(1, "通联");

    private final int value;

    private final String name;

    public static GangRelationTypeEnum getEnum(int value) {
        return Arrays.stream(values()).filter(tr -> tr.getValue() == value).findFirst().orElse(null);
    }

    public static GangRelationTypeEnum getEnum(String name) {
        if (name == null) return null;
        return Arrays.stream(values()).filter(tr -> tr.getName().equals(name)).findFirst().orElse(PERSON_CASE);
    }
}
